/**
 * @file The resource not found error handler
 * 
 * @author Steve Gao<gaofu@parllay.com>
 */
const BaseHandler     = require('../base-handler');
const HTTP_VERBS      = require('../../../constants').HTTP_VERBS;
const HTTP_STATUSES   = require('../../../constants').HTTP_STATUSES;

/**
 * The not found error handler
 * 
 * @description When user try to visit some url they don't have permission or not exists,
 * we will use this handler to handle
 * 
 * @class NotFoundErrorHandler
 * @extends {BaseHandler}
 */
class NotFoundErrorHandler extends BaseHandler {
    
    get pattern() {
        return "*";
    }

    doALL(request, response) {
        response.status(HTTP_STATUSES.NOT_FOUND).render('common/not-found-error');
    }

    setup() {
        this.registerVerb(HTTP_VERBS.ALL, this.doALL);
    }
}

module.exports = NotFoundErrorHandler;